﻿using Jjb.ScoresRanks.Net5.API.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Jjb.ScoresRanks.Net5.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class BaseController : ControllerBase
    {
        public static List<Customer> customers = null;
        static BaseController()
        {
            customers = new List<Customer>(){
                new Customer { CustomerID=15514665, Score=124, Rank=1 },
                new Customer { CustomerID=81546541, Score=113, Rank=2 },
                new Customer { CustomerID=1745431, Score=100, Rank=3 },
                new Customer { CustomerID=76786448, Score=100, Rank=4 },  
                new Customer { CustomerID=254814111, Score=96, Rank=5 },
                new Customer { CustomerID=53274324, Score=95, Rank=6 },
                new Customer { CustomerID=6144320, Score=93, Rank=7 },
                new Customer { CustomerID=8009471, Score=93, Rank=8 },
                new Customer { CustomerID=11028481, Score=93, Rank=9 },
                new Customer { CustomerID=38819, Score=92, Rank=10 }
            }.OrderByDescending(x => x.Score).ToList();

            foreach (var item in customers)
            {
                item.Rank = customers.IndexOf(item)+1;
            }
        }

    }
}
